package com.lx.commonlib.mvp.view.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.lx.commonlib.mvp.persenter.BasePresenter;
import com.lx.commonlib.mvp.view.IView.IBaseView;
import com.lx.commonlib.utils.AppManager;

/**
 * 类说明：应用中所有activity的基类,在这里进行一些统一的操作，比如说 透明状态栏、统一退出动画、activity统一管理等
 * Created by liuxiong on 2019/3/23.
 */

public abstract class BaseActivity<P extends BasePresenter> extends AppCompatActivity implements IBaseView {

    /** presenter层对象 */
    protected P mPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //加入到AppManager进行管理
        AppManager.getInstance().addActivity(this);
    }

    protected abstract P createPresenter();

    @Override
    public Activity getActivity() {
        return this;
    }

    @Override
    public Context getAppContext() {
        return getApplicationContext();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //从AppManager移除管理
        AppManager.getInstance().removeActivity(this);
    }

}
